<%--
  Created by IntelliJ IDEA.
  User: kurong
  Date: 2021/11/4
  Time: 8:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
<%--    <link rel="stylesheet" href="${pageContext.request.contextPath}/res/layui/css/layui.css">--%>

    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/generalMerchandise.css">

    <script src="${pageContext.request.contextPath}/res/jquery/jquery-3.5.1.min.js" rel="stylesheet"></script>

    <script src="${pageContext.request.contextPath}/js/generalMerchandise.js"></script>
</head>
<body>
<!--最上面的导航-->
<div class="shortcut-2014">
    <div class="w haha">
        <ul class="fr">
            <li class="fore1 fore1zidingyi " id="ttbar-login">
                <div class="user-info-no">

                    <a href="${pageContext.request.contextPath}/customer/login.jsp" class="link-login">你好，请登录</a>
                    &nbsp;&nbsp;
                    <a href="${pageContext.request.contextPath}/customer/register.jsp" class="link-regist style-red">免费注册</a>
                </div>

                <div class="user-info-yes">

                    <span style="font-size: 12px">欢迎</span>
                    &nbsp;&nbsp;
                    <span class="userNickName" style="color: red;"></span>
                    &nbsp;&nbsp;
                    <span style="font-size: 12px">登录</span>
                    &nbsp;&nbsp;
                    <button onclick="logout()" style="border:none; background-color: #e3e4e5" class="link-regist style-red">退出</button>
                </div>

            </li>

            <li class="fore2">
                <div class="dt">
                    <a class="order-href" href="${pageContext.request.contextPath}/customer/login.jsp" target="_blank">我的订单</a>
                    <%--                        <a href="" target="_blank">我的订单</a>--%>
                </div>
            </li>

        </ul>
    </div>
</div>

<script type="text/javascript" src="${pageContext.request.contextPath}/res/jquery/jquery-3.5.1.js"></script>
<script>
    $(document).ready(function () {
        $(".user-info-yes").hide();
        <%--cartUrl="${pageContext.request.contextPath}/myorder/${loginCustomer.custId}";--%>
        <%--orderUrl="${pageContext.request.contextPath}/shopcar/${loginCustomer.custId}";--%>
        $.get("${pageContext.request.contextPath}/cookie/login", null,
            function (result) {
                console.log(JSON.stringify(result));
                if (result.code==200){
                    cartUrl="${pageContext.request.contextPath}/shopcar";
                    orderUrl="${pageContext.request.contextPath}/myorder";

                    $(".user-info-no").hide();
                    $(".user-info-yes").show();
                    $(".userNickName").text(result.data.custNickname);
                    $(".order-href").attr("href",orderUrl);

                    $(".cart-href").attr("href",cartUrl);
                    $(".cart-href").attr("target","_blank");
                }else {
                }



            }, 'json');
    });

    function logout() {
        $.get("${pageContext.request.contextPath}/cust/logout",null,
            function(data){
                location.reload();
            },'json');
    }
</script>


</body>
</html>
